package com.lantu.core.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lantu.domain.UserEntity;
import com.lantu.utils.network.IpUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author binyuhuang
 * @since 2023-02-07
 */
@EqualsAndHashCode(callSuper = true)
@TableName("x_member")
@Data
public class Member extends UserEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    private String username;

    private String password;

    private String email;

    private String phone;

    private Integer status;

    private String avatar;

    private Integer deleted;

    public Member updateByLogin(HttpServletRequest request){
        this.setIp(IpUtils.getRemoteAddr(request));
        this.setLastLoginTime(new Date());
        return this;
    }

    @Override
    public String toString() {
        return "Member{" +
            "id=" + id +
            ", username=" + username +
            ", password=" + password +
            ", email=" + email +
            ", phone=" + phone +
            ", status=" + status +
            ", avatar=" + avatar +
            ", deleted=" + deleted +
        "}";
    }
}
